home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_06_04
/
v6n4052a.txt
< prev
next >
Wrap
Text File
|
1989-09-26
|
893b
|
43 lines
#include <stdio.h>
#include "q2.h"
#define LOOPS 20
main()
{
int i;
int k;
qele_type next;
qele_type rval;
/* initialization */
srand(12);
qele_cpy(next,q_NIL);
for (i=0; i<LOOPS; i++){
k = rand();
k &= q_WRAP;
printf("\n%d positions unused",q_free());
printf("\nInserting %d items starting with %d",k,next);
while (k--){
if (q_put(next) == FULL) {
printf("\nQueue full");
break;
}
else
qele_incr(next);
}
k = rand();
k &= q_WRAP;
printf("\n%d positions used",q_bsy());
printf("\nRemoving %d items ",k);
while (k--){
if ((rval = q_get()) == EMPTY){
printf("\nQueue Empty");
break;
}
else printf("\n %d",rval);
}
}
}